
public class Map {
	
	private int width,height;
    DataGame data;
	
	public Map()
	{
        
		DataGame.load();//load data 

        this.width = DataGame.ALL_MAP_DATA[0].w;
        this.height = DataGame.ALL_MAP_DATA[0].h;
       
      
		
	}
	public void loadMap(int idMap, int w, int h) 
	{  

		this.width=DataGame.ALL_MAP_DATA[idMap].w;
		this.height=DataGame.ALL_MAP_DATA[idMap].h;
	}
	//get width map
	public int GetWidth()
	{
		return this.width;
	}
	//get height map
	public int GetHeight()
	{
		return this.width;
	}
	int seque=0;
	public void update()
	{
		
		seque++;
		
	}
	public void paint(mGraphics g) 
	{

        for (int i = 0; i < DataGame.ALL_MAP_DATA[0].allBkgMap.size(); i++)
        {
            DataItemMap data = (DataItemMap)DataGame.ALL_MAP_DATA[0].allBkgMap.elementAt(i);
            g.drawImageScale(DataGame.LoadImage(data.idSmallImage), data.x, data.y, DataGame.LoadImage(data.idSmallImage).getWidth(), DataGame.LoadImage(data.idSmallImage).getHeight(), 0);
        }
        //draw tree on map
        for (int i = 0; i < DataGame.ALL_MAP_DATA[0].allItemInMap.size(); i++)
        {
            DataItemMap data = (DataItemMap)DataGame.ALL_MAP_DATA[0].allItemInMap.elementAt(i);
            g.drawImageScale(DataGame.LoadImage(data.idSmallImage), data.x, data.y, DataGame.LoadImage(data.idSmallImage).getWidth(), DataGame.LoadImage(data.idSmallImage).getHeight(), 0);
        }
        //draw effect on map
        for (int i = 0; i < DataGame.ALL_MAP_DATA[0].allEffect.size(); i++)
        {
            DataEffectMap effectMap = (DataEffectMap)DataGame.ALL_MAP_DATA[0].allEffect.elementAt(i);
            PaintEffect(g, effectMap);
        }
	}	
	
	private void PaintEffect(mGraphics g,DataEffectMap effect)
	{
		 int index = effect.id ;
        
//         for(int i=0;i< DataGame.Effects[index].sequences.size();i++)
//         {
//        	
//        	 Integer sequence =(Integer) DataGame.Effects[index].sequences.elementAt(i);
//			 int idSequence=sequence.intValue();
			 if(seque<DataGame.Effects[index].frames.size())
			 {
				 DataEFrame frames=(DataEFrame) DataGame.Effects[index].frames.elementAt(seque);
	             int countImage = frames.eImages.size();

	             for (int j = 0; j < countImage; j++)
	             {
	                 DataEImage eImage =(DataEImage) frames.eImages.elementAt(j);
                     //g.drawImage(DataGame.LoadImage(eImage.smallID), effect.x + eImage.dx, effect.y + eImage.dy,0);
                     g.drawImageScale(DataGame.LoadImage(eImage.smallID), effect.x + eImage.dx, effect.y + eImage.dy, DataGame.LoadImage(eImage.smallID).getWidth(), DataGame.LoadImage(eImage.smallID).getHeight(), 0);
	             }  	           
			 }
			 
			 else
			 {
				 seque=0;
			 }
			
//         }		
	}
}
